import axios from "@/utils/request"

const path = "/taskManager/a/mobile/mobileAllotTask/"
let testOAuthUser = null

// 设置testOAuthUser
export let settestOAuthUser = (AuthUser) => {
  testOAuthUser = AuthUser
}

// type:1,2,3
// 1:结算类型 => SETTLE_TYPE
// 2:结算分级 => SETTLE_LEVEL
// 3:结算标签 => gongzuoshixiangbiaoqian
export const SettlementByType = (type = 1) => {
  if (!type) return console.log("参数类型有误")

  let dictType = type === 1 ? "SETTLE_TYPE" : type === 2 ? "SETTLE_LEVEL" : "gongzuoshixiangbiaoqian"

  return axios.get(`${path}getDictByType`, {
    params: {
      dictType,
      testOAuthUser
    }
  })
}

// 任务类型
// http://hedaotest.gdpr.com/taskManager/a/mobile/mobileAllotTask/getTaskType?testOAuthUser=201205
export const TaskType = () =>
  axios.get(`${path}getTaskType`, {
    params: {
      testOAuthUser
    }
  })

// 特殊属性接口
// http://hedaotest.gdpr.com/taskManager/a/mobile/mobileAllotTask/getAttrByType?type=271
export const TaskSpecial = (type) =>
  axios.get(`${path}getAttrByType`, {
    params: {
      type
    }
  })

// 人员查询(param是过滤条件 可以填姓名或者工号)
// http://hedaotest.gdpr.com/taskManager/a/mobile/mobileAllotTask/findUserByParam?testOAuthUser=201205&rows=10&page=1&param=201205
export const findUserByParam = (param = null, page = 1) =>
  axios.get(`${path}findUserByParam`, {
    params: {
      testOAuthUser,
      page,
      param
    }
  })

// 保存
// http://hedaotest.gdpr.com/taskManager/a/mobile/mobileAllotTask/save
export const singleSave = (data) =>
  axios.post(`${path}save`, {
    ...data
  })
